Rivest Problem Set 3 Solutions
نویسنده
چکیده
Problem 3-1. Prime Triangles. TA Notes: It is a little-known fact (to us, anyway) that the Java 1.4.1 class library contains a bug in part of its primality tester. Specifically, the Lucas-Lehmer test is implemented incorrectly, and sometimes reports that certain large numbers are composite when they are actually prime. This slowed down our own trianglefinding algorithm for large values of k, and also caused some false alarms during grading. Fortunately, the bug is fixed in version 1.4.2. Most good solutions (and our own, as well) used the following general framework: pick a value a (it helps if a is prime, so that it’s relatively prime to all b and c), then find many values of b that form a “prime pair” with a (i.e., both a ◦ b and b ◦a are prime). For each newly-found value of b, see if it forms a prime pair with any previously-found value c; if so, return (a, b, c) as a prime triangle. For a fast implementation of the above algorithm, there are several optimizations that can be used before employing full Miller-Rabin tests: the Sieve of Eratosthenes, small prime divisor tests, and greatest common divisor tests. While this strategy works very well, the search time for k-digit prime triangles seems to vary wildly, even for fixed k. This is probably due to the fact that some a values can work in many triangles, while others cannot belong to any at all (a = 73 is one example for k = 2). The running time, then, dramatically depends upon how lucky we are at choosing a good initial value of a. It also seems that code written in C (using the GMP toolkit, for example) still has significant performance advantages over code written in Java. Groups that wrote their programs in C typically were able to find triangles for larger values of k than groups who used Java, using comparable algorithms. For grading, we reserved the top scores (9s and 10s) for groups who described good algorithms and found triangles for k = 40 or higher. A decent algorithm and a value of k = 20 or higher typically earned 7 to 8 points. Using an algorithm similar to the one below (but written in C), the group of Alexandros Kyriakides, Saad Shakshir, and Ioannis Tsoukalidis found a prime triangle for k = 140. The following is our (heavily-commented) implementation of a prime triangle-finder, in Java. With it, we were able to find a prime triangle for k = 100 in about 30 minutes on an Athlon 1.4 GHz machine running Debian Linux. On average and on the same hardware, we are able to find a prime triangle for k = 140 in about 6 hours. The code can be downloaded from the 6.857 website.
منابع مشابه
Rivest Problem Set 2 Solutions Problem 1 - 1 . One - Time Pads
0 ≤ xi ⊕ yi < 16 for all individual bytes i ∈ [0, 191]. Therefore, by taking two encoded messages x′ = x ⊕ p and y′ = y⊕ q and XORing them together, we get x′⊕ y′ = (x⊕ y)⊕ (p⊕ q), which in turn equals x⊕ y if they used the same pad p = q. So, if all bits of x′ ⊕ y′ are less than 16, we can be reasonably certain that the same OTP was used; otherwise, we can be fully certain that different OTPs ...
متن کاملCharacterization of efficient points of the production possibility set under variable returns to scale in DEA
We suggest a method for finding the non-dominated points of the production possibility set (PPS) with variable returns to scale (VRS) technology in data envelopment analysis (DEA). We present a multiobjective linear programming (MOLP) problem whose feasible region is the same as the PPS under variable returns to scale for generating non-dominated points. We demonstrate that Pareto solutions o...
متن کاملWell-dispersed subsets of non-dominated solutions for MOMILP problem
This paper uses the weighted L$_1-$norm to propose an algorithm for finding a well-dispersed subset of non-dominated solutions of multiple objective mixed integer linear programming problem. When all variables are integer it finds the whole set of efficient solutions. In each iteration of the proposed method only a mixed integer linear programming problem is solved and its optimal solutions gen...
متن کاملSolving Environmental/Economic Power Dispatch Problem by a Trust Region Based Augmented Lagrangian Method
This paper proposes a Trust-Region Based Augmented Method (TRALM) to solve a combined Environmental and Economic Power Dispatch (EEPD) problem. The EEPD problem is a multi-objective problem with competing and non-commensurable objectives. The TRALM produces a set of non-dominated Pareto optimal solutions for the problem. Fuzzy set theory is employed to extract a compromise non-dominated sol...
متن کاملLearning Action Strategies for Planning Domains Learning Action Strategies for Planning Domains
This paper reports on experiments where techniques of supervised machine learning are applied to the problem of planning. The input to the learning algorithm is composed of a description of a planning domain, planning problems in this domain, and solutions for them. The output is an eecient algorithm | a strategy | for solving problems in that domain. We test the strategy on an independent set ...
متن کاملAnalysis of the efficiency of the Chor-Rivest cryptosystem implementation in a safe-parameter range
The Chor-Rivest cryptosystem, based on a high-density knapsack problem on a finite field Fqh , was broken by S. Vaudenay for q ≈ 200, h ≈ 24, and h admitting a factor s verifying a certain condition. A new set of parameters q and h, which prevent this cryptosystem against Vaudenay’s attack, is presented and the computational aspects of its implementation in the Magma computational algebra syste...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2003